//
//  LineViewController.m
//  Tospur-text
//
//  Created by Tospur_hewei on 15/9/29.
//  Copyright (c) 2015年 Tospur_hewei. All rights reserved.
//

#import "LineViewController.h"
#import <BMapKit.h>
@interface LineViewController ()<BMKMapViewDelegate>
@property (nonatomic,strong) BMKMapView *mapView;
@end

@implementation LineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
    [self.view addSubview:_mapView];
    
    // 添加折线覆盖物
    CLLocationCoordinate2D coors[4] = {0};
    coors[0].latitude = 31.240;
    coors[0].longitude = 121.459;
    coors[1].latitude = 31.340;
    coors[1].longitude = 121.559;
    coors[2].latitude = 31.340;
    coors[2].longitude = 121.659;
    coors[3].latitude = 31.240;
    coors[3].longitude = 121.659;
    self.mapView.delegate = self;
    BMKPolyline* polyline = [BMKPolyline polylineWithCoordinates:coors count:4];
    [self.mapView addOverlay:polyline];
    [self.mapView  setCenterCoordinate:coors[1] animated:YES];
}

// Override
- (BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id <BMKOverlay>)overlay{
    if ([overlay isKindOfClass:[BMKPolyline class]]){
        BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay] ;
        polylineView.strokeColor = [[UIColor purpleColor] colorWithAlphaComponent:1];
        polylineView.lineWidth = 5.0;
        
        return polylineView;
    }
    return nil;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
